#include "CountDevice.h"
#include <stdio.h>
#include <string.h>

CountDevice::CountDevice(int start)
{
	_startAt = start;
}

CountDevice::~CountDevice()
{
}

int CountDevice::open()
{
	_counter = _startAt;
	_isOpen = 1;
	printf("Count device open\n");
}

void CountDevice::close()
{
	_isOpen = 0;
	printf("Count device closed\n");
}

int CountDevice::read()
{
	if (!_isOpen)
	{
		printf("Read failed: count device not open\n"); 
		_counter = 0;
	}
	return _counter++;
}
